package com.dinetech.dao;

import java.util.ArrayList;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import com.dinetech.entidades.Galpon;

public class WSGalpon {

	final String NAMESPACE = "http://www.CuyTechService.pe/WSservice2005/";//"http://192.168.1.10/WebService/";                        
    final String URL= "http://www.cuytechservice.pe/WsCuyTech2005/SoapDataServices.asmx";//"http://192.168.1.10/WSservice2005/SoapDataServices.asmx";
                
   public ArrayList<Galpon> WSListarGalpon (int IdSucur){
                                      
       final String METHOD_NAME = "SeleccionarGalpon";
       final String SOAP_ACTION = NAMESPACE + METHOD_NAME;
                               
       SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);                                          
       request.addProperty("IdSucursal", IdSucur);    
                               
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
       envelope.dotNet = true;
       envelope.setOutputSoapObject(request);
                               
       ArrayList<Galpon> lisGalpon = new ArrayList<Galpon>();
       HttpTransportSE transporte = new HttpTransportSE(URL);
     
     	try{
            transporte.call(SOAP_ACTION, envelope);                                                       
            SoapObject respSoap=(SoapObject)envelope.getResponse();
                                                               
            for(int i=0; i < respSoap.getPropertyCount(); i++){
                                        
             SoapObject ic =(SoapObject)respSoap.getProperty(i);
             lisGalpon.add(new Galpon(Integer.parseInt(ic.getPropertyAsString("IdGalpon").toString()), ic.getPropertyAsString("Descripcion")));
            }

            }catch(Exception e){
                                                               
            }                                             
             return lisGalpon;
    }
                


}
